package com.kim.smartring.utils;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;

public class DateUtils {

	private static SimpleDateFormat dateFormat = new SimpleDateFormat(
			"yyyy-dd", Locale.CHINA);
	private static SimpleDateFormat hourSecond = new SimpleDateFormat("HH:mm",
			Locale.CHINA);

	/**
	 * 获取当天时间的起始时间
	 * 
	 * @return
	 */
	public static long getCurrentDayStartTime() {
		Calendar calendar = Calendar.getInstance();
		calendar.set(Calendar.HOUR, 0);
		calendar.set(Calendar.MINUTE, 0);
		calendar.set(Calendar.SECOND, 0);
		return calendar.getTimeInMillis();
	}

	/**
	 * 获取当天天数
	 * 
	 * @return
	 */
	public static String getCurrentDay() {
		Calendar calendar = Calendar.getInstance();
		return String.valueOf(calendar.get(Calendar.DAY_OF_MONTH));
	}

	/**
	 * 获取年月 格式：2014-05
	 * 
	 * @return
	 */
	public static String getYearMonth() {
		Calendar calendar = Calendar.getInstance();
		Date date = calendar.getTime();
		return dateFormat.format(date);
	}

	/**
	 * 获取时间字符 格式 08:34
	 * 
	 * @param alarmTime
	 * @return
	 */
	public static String getHourSecond(long alarmTime) {
		Calendar calendar = Calendar.getInstance();
		calendar.setTimeInMillis(alarmTime);
		return hourSecond.format(calendar.getTime());
	}
}
